Lists

_________________________________________________
                       (in)
 *288*

Input names: aList;  Item;  [StartIndex]

Input types: list;  <any>;  [integer]

Defaults: StartIndex = 1

Output names: FoundIndex

Output types: integer

Description: 
FoundIndex is the position in aList of the first occurrence of Item after the position specified by StartIndex. FoundIndex is 0 if Item does not occur in the list. Note that a list element is found only if it equals Item in the sense defined by the = primitive.

See also:  (length), (join)

_________________________________________________
                                 (join)
 *288*

Input names: List1;  List2;  [List3;  ...]

Input types: list;  list;  [list;  ...]

Output names: aList

Output types: list

Description: 
AList is the concatenation of List1, List2, … .

See also:  (in), (join)

_________________________________________________
                                    (length)
 *288*

Input types: list

Output types: integer

Description: 
Length is the length (number of elements) of aList.

See also:  (in), (join)

_________________________________________________
                                     attach-l
 *289*

Input names: Element1;  [Element2;  ...];  aList

Input types: <any>;  [<any>;  ...];  list

Output names: NewList

Output types: list

Description: 
NewList is the concatenation of lists (Element1... ) and aList.

See also:  detach-l, attach-r, detach-r,detach-nth

_________________________________________________
                                  attach-r
 *289*

Input names: aList;  Element1;  [Element2;  ...]

Input types: list;  <any>;  [<any>; ...]

Output names: NewList

Output types: list

Description: 
NewList is the concatenation of lists aList and (Element1...).

See also:  attach-l, detach-l, detach-r,detach-nth

_________________________________________________
                                detach-l
 *289*

Input names: aList

Input types: list

Output names: Element1;  [Element2;  ...; ElementN];  Tail

Output types: <any>;  [<any>;  ...; <any>];  list

Description: 
Length of aList must be at least N. Element1, …, ElementN are the first N elements of aList, and Tail is the list of remaining elements of aList.

See also:  attach-l, attach-r, detach-r,detach-nth

_________________________________________________
                                    detach-nth
 *290*

Input types: list;  integer

Output types: list;  <any>

Description: 
Element is the Nth element of InList. OutList is the list that results from removing the Nth element from InList.

See also:  attach-l, detach-l, attach-r, detach-r

_________________________________________________
                                    detach-r
 *290*

Input names: InList

Input types: list

Output names: OutList; Element1;  [Element2;  ...; ElementN]

Output types: list;  <any>;  [<any>;  ...; <any>]

Description: 
Length of InList must be at least N. Element1, …, ElementN are the last N elements of InList, and OutList is the list of remaining elements of InList.

See also:  attach-l, detach-l, attach-r, detach-nth

_________________________________________________
                                     find-sorted
 *290*

Input names: List; Item; [AttributeName]

Input types: list; string | number; [string]

Output names: Found; Index

Output types: boolean, integer

Description: Uses a binary search to find Item in a sorted list. With AttributeName, the list must be a list of instances. If Item is not found, Index is the location in the list where Item can be inserted. The advantage to searching sorted lists using find-sorted (as opposed to find-instance) is that find-sorted is faster because it uses a binary search.

_________________________________________________
 
                            get-nth
 *291*

Input names: aList;  N1;  [N2; …]

Input types: list;  integer;  [integer; …]

Output types: <any>

Description: 
Element is the indexed element of aList. With inputs of N1 and N2, get-nth returns the N2th element of the N1th list in aList.

See also:  set-nth, set-nth!

_________________________________________________
                                            insert-nth
 *291*

Input types: list; any; integer

Output types: list

Description: NewList is the list obtained by inserting Element into OldList at the Index position. If Index is 0, Element is the first item in NewList.

_________________________________________________
 
                                 make-list
 *292*

Input names: Length;  [Start;  [Step]]

Input types: integer; [<number>; [<number>]]

Defaults: Step = 0

Output names: aList

Output types: list

Description: 
aList is a list of length Length. If Start is not present, all elements of aList are NULL. If Step is not present, all the elements are Start. Otherwise, the first element of aList is Start, and every other element equals the element to its left plus Step.

See also:  pack

_________________________________________________
                                              pack
 *292*

Input names: Element1;  [Element2;  ...]

Input types: <any>;  [<any>;  ...]

Output names: aList

Output types: list

Description: AList is the list (Element1 ... ).

See also:  make-list, unpack

_________________________________________________
                                reverse
 *292*

Input types: list

Output types: list

Description: 
OutList is the reverse of InList.

_________________________________________________
                                              set-nth
 *293*

Input names: InList;  Item;  N1;  [N2; …]

Input types: list;  <any>;  integer;  [integer; …]

Output types: list

Description: 
Replaces the indexed element of InList by Item to produce the OutList list. If indeces are N1 and N2, set-nth returns a list with the N2nd element of the N1st list in InList replaced by Item.

See also:  get-nth, set-nth!

_________________________________________________
                                                    set-nth!
 *293*

Input names: aList;  Item;  N1;  [N2; …]

Input types: list;  <any>;  integer;  [integer; …]

Output types: list

Description: 
Replaces the indexed element of aList by Item. The indeces permit identifying an element within nested lists. Use this primitive with care, as it modifies its input data directly, rather than modifying copies of that data. Its side effects that can affect results of other operations which independently reference the same data. Use synchros to ensure desired results.

Side effect: 
The input list is modified!

See also:  set-nth, get-nth

_________________________________________________
                        sort
 *293*

Input names: InList; boolean; [AttributeName]

Input types: list; boolean; [string]

Output types: list

Description: Without AttributeName, sorts a list of numbers or strings. Otherwise sort a list of instances by AttributeName. The second input indicates whether duplicate items in the list should be eliminated. Default behavior is to retain duplicate items. 

_________________________________________________
 
                               split-nth
 *294*

Input types: list;  integer

Output types: list;  list

Description: 
Prefix and Rest are, respectively, the list consisting of the first N elements of aList and the remaining elements of aList.

_________________________________________________
                                           unpack
 *294*

Input names: aList

Input types: list

Output names: Element1;  [Element2;  ...; ElementN]

Output types: <any>;  [<any>;  ...]

Description: 
Length of aList must be at least N. Element1, ..., ElementN are the first N elements of aList.

Example:

 

 
See also:  make-list, pack